package com.zhumo.sz.mapper;

import com.zhumo.sz.entity.bus.*;
import com.zhumo.sz.provider.BatchInsertProvider;
import com.zhumo.sz.provider.BatchNestCorrespondentProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface TransitMapper {

    @InsertProvider(type = BatchNestCorrespondentProvider.class,method = "batchInsert")
    int addBusStation(@Param("list") List<BusSiteInfo> busSiteInfoList);

    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addBusLine(@Param("list") List<BusLineInfo> busLineInfoList);

    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addLengthBusStation(@Param("list") List<LengthBusStationInfo> lengthBusStationInfoList);

    /**
     * 批量插入 长途车班次信息
     */
    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addLengthBusScheduler(@Param("list") List<LengthBusDepartureScheduleInfo> lengthBusDepartureScheduleInfoList);

    /**
     * 批量插入 公交车订单信息
     */
    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addBusOrder(@Param("list") List<BusOrderDetail> busOrderDetailList);



    /**
     * 批量插入 长途客运汽车信息
     * @param lengthBusList
     * @return
     */
        @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
        int batchAddLengthBus(@Param("list") List<LengthBus> lengthBusList);

    /**
     * 查询所有公交公司信息
     * @return
     */
    @Select("select * from bus_operator_company")
    List<BusOperatorCompany> getAllBusOperatorCom();

    /**
     * 查询所长途公交站id
     */
    @Select("select station_code from length_bus_station_info;")
    List<String> getAllLengthStationCode();

    /**
     * 删除所有长途客运班次 LengthBusDepartureScheduleInfo
     */
    @Update("TRUNCATE table length_bus_departure_schedule_info")
    int clearAllLengthBusScheduler();

    @Select("select * from length_bus_station_info where station_code = #{stationCode};")
    LengthBusStationInfo getStationByCode(@Param("stationCode") String stationCode);

    /**
     * 查询所有长途客运汽车信息
     */
    @Select("select * from length_bus")
    List<LengthBus> getAllLengthBusInfo();

    /**
     * 获取所有市内公交线路信息
     */
    @Select("select * from bus_line_info;")
    List<BusLineInfo> getAllBusLine();

    /**
     * 获取所有公交订单信息
     */
    @Select("select bus_order_id from bus_order_detail;")
    List<String> getAllHistoryBusOrder();

    /**
     * 根据名称获取编码
     */
    @Select("select * from bus_site_info where site_name = #{siteName};")
    BusSiteInfo getBusSiteByName(@Param("siteName") String siteName);


    @Select("select * from length_bus_departure_schedule_info wehere station_code = '#{stationCode}'")
    List<LengthBusDepartureScheduleInfo> getSchByStation(@Param("stationCode") String stationCode);


    /**
     * 批量插入
     * @return
     */
    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addLengthBusTickets(@Param("list") List<LengthBusTickingDetail> lengthBusTickingDetailList);
}

